/*******************************************************************
* ++
* Author        :	ThienTN
* Description   :	Main.cpp in project HRManage
* 
* Mod. History  :	26/07/2012 - ThienTN
*
* --
*******************************************************************/
#include "Employee.h"
#include "Student.h"
#include "Staff.h"
#include "Manager.h"
#include "Utility.h"

int main()
{
	bool bFlag = true;
	int nChoice;
	int nEmpType;
	List m_list;
	Node *pNode;
	CEmployee *pEmployee;
	CreateList(&m_list);
	do
	{
		//Show menu
		Menu();
		// Input a chose
		cout << "Input your chose: ";
		cin >> nChoice;
		cin.ignore(1);
		switch (nChoice)
		{
			case 1:
				// Input Employee
				char chStop;
				do
				{
					// Menu Employee Type
					cout << "Input Employee information" << endl;
					cout << "\t\tSTUDENT : 0 " << endl;
					cout << "\t\tSTAFF   : 1 " << endl;
					cout << "\t\tMANAGER : 2 " << endl;
					cout << "Input Employee Type: " ;
					cin >> nEmpType;
					cin.ignore(1);
					// Input Employee Type
					while (nEmpType > 2 || nEmpType < 0)
					{
						cout << "Input Employee Type: " ;
						cin >> nEmpType;
						cin.ignore(1);
					}
					// Create new Employee
					switch (nEmpType)
					{
						case 0:
							pEmployee = new CStudent();
							break;
						case 1:
							pEmployee = new CStaff();
							break;
						case 2:
							pEmployee = new CManager();
							break;
						default:
							cout << "Please enter another chose\n";
							break;

					}
					cout << "Input employee info:" << endl;
					pEmployee->inputEmployee(pEmployee);
					pNode = CreateNode(pEmployee);
					AddHead(&m_list, pNode);
					End();
					printf("Do you want to continues ? (Y/N) ");
					cin.ignore(1);
					chStop = getchar();
					End();
				}while(chStop != 'n' && chStop != 'N');
				break;
			case 2:
				// Search a Employee belong to name
				// Input name
				pEmployee->searchEmployee(&m_list, pEmployee);	
				End();
				break;
			case 3:
				// Sort Employee belong to birthday
				pEmployee->sortName(&m_list);
				End();
				break;
			case 4:
				// Sort Employee belong to birthday
				pEmployee->sortEmpType(&m_list);
				End();
				break;
			case 5:
				// Display list Employee
				pNode = m_list.pHead;
				while (pNode != NULL)
				{
					pNode->info->Display();
					pNode = pNode->pNext;
				}
				End();
				break;
			case 6:
				// Search a Employee belong to name
				pEmployee->RemoveEmployee(&m_list);
				End();
				break;
			case 0:
				// Quit program
				bFlag = false;			
				break;
			default:
				// Exception case
				cout << "Please enter another chose\n";
				break;
		}
	}while (bFlag);

	// Release memory using
	//delete pNode;
	return 0;
	return 0;
}